<template>
	<view class="">
		<view class="box" v-for="(item,index) in list" :key="index" @click="particulars(item)">
			<image :src="item.commodity.img  || item.img" mode=""></image>
			<view class="rightbox">
				<view class="name">
					{{item.commodity.name || item.name}}
				</view>
				<view class="centerbox">
					<text class="danwei">￥</text>
					<text class="jiage">{{item.commodity.prices || item.prices}}</text>
					<text class="xiaoliang">
						销量：{{item.commodity.sale_num || item.sale_num}}
					</text>
				</view>
				<view class="remark" v-if="shows" >
					评论条数：{{item.getcomment_count}}
				</view>
				<view class="" v-if="flag">
					<view class="addcar" v-if="isShow">
						加入购物车
					</view>
					<view class="btn" v-else @click="delet(item)">
						删除
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array,
				default: []
			},
			isShow: {
				type: Boolean,
				default: true
			},
			flag:{
				type:Boolean,
				default:true
			},
			shows:{
				type:Boolean,
				default:false
			}
		},
		methods: {
			delet(v) {
				this.$emit('confirm', v)
			},
			particulars(v){
				this.$emit('particulars',v)
			}
		}
	}
</script>

<style scoped lang="scss">
	.box {
		display: flex;
		margin-top: 20rpx;
		background-color: #FFFFFF;

		image {
			width: 231rpx;
			height: 231rpx;
		}

		.rightbox {
			margin-left: 20rpx;

			.name {
				font-family: SourceHanSansCN-Regular;
				font-size: 28rpx;
				color: #000000;
				width: 472rpx;
				// overflow: hidden;
				// white-space: nowrap;
				// text-overflow: ellipsis;
			}

			.centerbox {
				margin-top: 30rpx;

				.danwei {
					font-family: PingFang-SC-Heavy;
					font-size: 22rpx;
					color: #e13c35;
				}

				.jiage {
					font-family: PingFang-SC-Heavy;
					font-size: 36rpx;
					color: #e13c35;
					margin-left: 5rpx;
				}

				.xiaoliang {
					font-family: PingFang-SC-Medium;
					font-size: 18rpx;
					color: #838383;
					margin-left: 41rpx;
				}
			}

			.btn {
				width: 100rpx;
				height: 53rpx;
				background-color: #ffffff;
				border-radius: 27rpx;
				border: solid 2rpx #ee1616;
				font-family: PingFang-SC-Medium;
				font-size: 22rpx;
				color: #e13c35;
				line-height: 53rpx;
				text-align: center;
				margin-top: 37rpx;
				margin-left: 370rpx;
			}

			.addcar {
				width: 171rpx;
				height: 53rpx;
				background-color: #ffffff;
				border-radius: 27rpx;
				border: solid 2rpx #ee1616;
				font-family: PingFang-SC-Medium;
				font-size: 22rpx;
				color: #e13c35;
				line-height: 53rpx;
				text-align: center;
				margin-top: 37rpx;
				margin-left: 307rpx;
			}
		}
	}
	.remark{
		margin-top: 29rpx;
		font-size: 26rpx;
		color: #999999;
	}
</style>
